package com.yjz.jvm.juc.Lock.ReentrantLockLearn;

/**
 * @author yjz
 */
public class DecreaseThread extends Thread {

    private  Target target;

    public DecreaseThread(Target target,String name) {
       this.target=target;
       super.setName(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 30; i++) {
            try {
                Thread.sleep((long) Math.random() * 500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            target.decrease();
        }
    }
}
